﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddAgentQlty2.aspx.cs" Inherits="IHISCETeim.Web.AgentSys.SvrMgr.AddAgentQlty2" %>

    <div class="pageContent">
	<form method="post" action="SvrMgr/AddAgentQlty2.aspx?ajaxmethod=add" class="pageForm required-validate" onsubmit="return validateCallbackFTradeReceivablesAdd(this, navTabAjaxDone);">
		<div class="pageFormContent" layoutH="56">
                <h2 style=" padding:0px 0px 5px 6px; border-bottom:1px solid #B8D0D6;">1.基本信息</h2>
                    <div style="width:760px">
			            <p>
				            <label>品 情 号：</label>
				            <input name="TextBox1" type="text" class="" readonly value="自动生成" />
			            </p>
			            <p>
				            <label>发行日期：</label>
				            <input name="IssueDate" class="required date" type="text" format="yyyy-MM-dd HH:mm" value="<%=DateTime.Now.ToString("yyyy-MM-dd HH:mm") %>" alt=""/>
			            </p>
                         <%if(User.UserType==2){ %>
                        <div style="clear:both;"></div>
                        <label>服务担当：</label>
                        <input name="SvrInfo" type="text" class="" readonly style="width:300px" value="<%=GetSvrInfo() %>" />
                        <%} %>
                    </div>
                    <div class="divider"></div>
                    <div style="float:left; width:760px" class="uwarrantycardInfo"> 

			            <p>
				            <label>经 销 商：</label>
                            <%if(User.UserType==1){ %>
                                <select name="AgentUserId">
                                    <%=GetMyAgent() %>
                                </select>
                            <%} else{%>
                                <input name="AgentName" type="text" readonly class="required textInput" value="<%=User.Department %>" />
                            <%} %>
			            </p>

                     
                        <p>
				            <label>机号：</label>
				            <input id="AddAgentQltySerialNumber" name="SerialNumber" class="required" type="text"  value="" alt=""/>
			            </p>
                         <div style="clear:both;"></div>
                         <p>
				            
			            </p>
                        <p>
				            <label>&nbsp;</label>
                            <a href="#" onclick="onrefreSerialNumberClick()" style="color:red;">手工刷新机号信息</a>
			            </p>
                         <div  style="clear:both;"></div>
                        <p>
				            <label>用户：</label>
				            <input name="CustomerName" class="required" type="text"  value="" alt=""/>
			            </p>
                        <p>
				            <label>用户手机：</label>
				            <input name="CustomerMobile" class="required" type="text"  value="" alt=""/>
			            </p>
                        <p>
				            <label>交机日：</label>
				            <input name="IntoDate" class="date" type="text"  value="" alt=""/>
			            </p>
                        <p>
				            <label>地点：</label>
				            <input name="IntoAddress" class="required" type="text"  value="" alt=""/>
			            </p>
                        <p>
				            <label>故障日：</label>
				            <input name="FaultDate" class="date required"  format="yyyy-MM-dd HH:mm" type="text"  value="" alt=""/>
			            </p>
                        <p>
				            <label>机型：</label>
				            <input name="MachineType" class="required" type="text"  value="" alt=""/>
			            </p>
                        <p>
				            <label>工作小时：</label>
				            <input name="WorkHour" class="required inputFloat" type="text"  value="0" alt=""/>
			            </p>
                        <p>
				            <label>报告人：</label>
				            <input name="ReportUser" class="required" type="text"  value="" alt=""/>
			            </p>
                         <p>
				            <label>联系电话：</label>
				            <input name="ReportTel" class="required" type="text"  value="" alt=""/>
			            </p>
                         <p>
				            <label>损坏部品序列号或钢号：</label>
				            <input name="DamagePartsNumber" class="" type="text"  value="" alt=""/>
			            </p>
                    </div>
                    <div style="float:left;width:380px; padding:5px 0px;" class="uwarrantycardInfo">
                         <p>
                             <label>机器性质：</label>
                             <select name="MacNature" class="">
                                 <option value="代理商库存机">代理商库存机</option>
                                 <option value="IHISCE样机">IHISCE样机</option>
                                 <option value="终端客户机" selected>终端客户机</option>
                             </select>
                        </p>
                        <p>
                             <label>作业内容：</label>
                             <select name="IntoConditi" class="">
                                 <option value="土方" selected>土方</option>
                                 <option value="砂石">砂石</option>
                                 <option value="采石">采石</option>
                                 <option value="挖砂">挖砂</option>
                                 <option value="造园">造园</option>
                                 <option value="其他">其他</option>
                             </select>
                        </p>
                        <p>
                             <label>特别附件及规格：</label>
                             <select name="IntoSpecial" class="">
                                 <option value="破碎管路">破碎管路</option>
                                 <option value="破碎专用">破碎专用</option>
                                 <option value="加宽铲斗">加宽铲斗</option>
                                 <option value="加长臂">加长臂</option>
                                 <option value="其他">其他</option>
                                 <option value="标准规格" selected>标准规格</option>
                             </select>
                        </p>
                    </div>
                 <div style="clear:both;"></div>
                 <h2 style=" padding:0px 0px 5px 6px; border-bottom:1px solid #B8D0D6; clear:both; margin-top:15px;">2.故障信息</h2>
                    
                    <div style="float:left; width:380px; margin-right:10px;"> 
                        <label style="width:250px!important;">故障描述(工况、故障部位、故障现象)：</label>
                        <div style="clear:both;margin-bottom: 5px;"></div>
				        <textarea name="FaultDescription" style="height:205px; width:375px;" ></textarea>

                        <div style="clear:both;margin-bottom: 5px;"></div>
                        <label style="width:250px!important;">故障推定原因：</label>
                        <div style="clear:both;margin-bottom: 5px;"></div>
				        <textarea name="FaultReason"  style="height:205px; width:375px;" ></textarea>

                        <label style="width:250px!important;">结论：</label>
                        <div style="clear:both;margin-bottom: 5px;"></div>
				        <textarea name="ProcessMode" style="height:265px; width:375px;" ></textarea>
                    </div>
                    <div style="float:left;width:445px;">
                        <label style="width:250px!important;">故障描述(工况、故障部位、故障现象)：</label>
                        <div style="clear:both;margin-bottom: 5px;"></div>
                         <asp:repeater id="rpImgs" runat="server">                    
                            <ItemTemplate>
                                <div style="float:left; height:210px; width:210px; margin-bottom:25px;">
                                    <img id="imgShow<%# Eval("id") %>" src="/res/blank.png"  Width="200" Height="150"/>
                                    <div style="clear:both;margin-bottom:2px;"></div>
                                    <table border="0" width="100%">
                                        <tr>
                                            <td><input type="file" name="filedata" id="imgRelativelyupload<%# Eval("id") %>" uploadify="uploadify" clientId="imgShow<%# Eval("id") %>,imgRelatively<%# Eval("id") %>" dirtype="4" foldername="<%=User.Department %>" onUploadSuccess="onAgentQltyUploadImgSuccess" fileTypeDesc="只能上传图片" fileTypeExts="*.jpg;*.gif;*.jpeg;*.png;*.bmp" fileSizeLimit="1MB"/></td>
                                            <td><a href="#" onclick="onAgentQltyDeleteUpload(<%# Eval("id") %>)" >删除</a></td>
                                        </tr>
                                    </table>
                                    <div style="clear:both;margin-bottom:2px;"></div>
                                    <input type="hidden"  id="imgRelatively<%# Eval("id") %>" name="imgRelatively" value="/res/blank.png" />
                                    <input type="text" name="ImgTitle" style="width:200px" value="图<%# Eval("id") %>:<%# Eval("ImgTitle") %>" />                         
                                </div>
                            </ItemTemplate>
                        </asp:repeater>

                        <div style="height:2px; clear:both; margin-bottom:-25px;"></div>
                        <div style=" width:210px;">
                            <label style="width:250px!important;">其它文件上传(不能超过10M)：</label>                            
                            <div style="clear:both;margin-bottom:2px;"></div>
                            <input type="hidden" name="imgRelatively" id="imgRelatively7" />
                             <input type="hidden" name="ImgTitle"  value="其它文件" />
                            <input type="file" name="filedata" id="imgRelativelyupload7" uploadify="uploadify" clientId="imgRelatively7" dirtype="4" foldername="<%=User.Department %>" onUploadSuccess="onAgentQltyUploadFileSuccess" fileSizeLimit="10MB"/>
                        </div>
                    </div>
                <div style="clear:both;"></div>
                <h2 style=" padding:0px 0px 5px 6px; border-bottom:1px solid #B8D0D6; clear:both; margin-top:15px;">3.部品需求(只有填写配件号的行才会被保存)</h2>
                    <div style="padding:5px 0px; margin-bottom:5px;">
                            <p>
				                <label>部品收件人：</label>
				                <input name="PartsAcceptName" class="" type="text"  value="<%=GetLastPartsAccept("PartsAcceptName") %>" alt=""/>
			                </p>
                            <p>
				                <label>联系电话：</label>
				                <input name="PartsAcceptTel" class="" type="text" value="<%=GetLastPartsAccept("PartsAcceptTel") %>"  alt=""/>
			                </p>
                            <p>
				                <label>期望到货时间：</label>
				                <select name="PartsAcceptDate">
                                    <option value="">请选择...</option>
                                    <option value="1-2天">1-2天</option>
                                    <option value="2-3天">2-3天</option>
                                    <option value="3天-1周">3天-1周</option>
                                    <option value="1周以上">1周以上</option>                                   
				                </select>
			                </p>
                          <div style="clear:both;"></div>
				            <label>部品收货地址：</label>
				            <input id="PartsAcceptAddress" name="PartsAcceptAddress" class="" type="text" size="100"  value="<%=GetLastPartsAccept("PartsAcceptAddress") %>"  alt=""/>
			        </div>
                    <div style="clear:both; "></div>
                    <table class="list"  style="width:100%" >
                       <thead>
                         <tr>
                                    <th width="50px">#</th>
                                    <th width="150px">配件号</th>
                                    <th width="150px">配件名</th>
                                    <th width="150px">数量</th>
                                    <th width="250px">配件需求</th>
                          </tr>                                
                        </thead>
                        <tbody>
                        <asp:repeater id="rpParts" runat="server">                    
                            <ItemTemplate>
                                 <tr>
                                     <td><%# Eval("Id") %></td>
                                     <td>
                                         <input type="text" name="ItemCode" id="dwz.opaV2Lookup.ItemCode<%# Eval("Id") %>" class="" showinputid="rpParts_Dscription_<%# Eval("Id") %>" autocompletehref="<%=AgentAutoCompleteUrl %>?ajaxmethod=getoitmlist&showtype=102" swidth="300" />
                                         <a class="btnLook" href="/MachineSys/SAPItemListLookUp.aspx?inputtag=<%# Eval("Id") %>" lookupgroup="opaV2Lookup" maxable="false" width="600" resizable="false" title="选择配件">
                                            <hi:text key="查找带回" />
                                        </a>
                                     </td>
                                     <td>
                                         <input type="text" id="dwz.opaV2Lookup.ItemName<%# Eval("Id") %>"  name="Dscription" />

                                     </td>
                                     <td><input type="text" name="Quantity" value="1" /></td>
                                     <td>
                                         <select name="PartsDemand">
                                             <option value="索赔发货" selected>索赔发货</option>
                                             <option value="索赔发货(补件)">索赔发货(补件)</option>
                                              <option value="索赔加急发货">索赔加急发货</option>                                             
                                              <option value="服务支持件">服务支持件</option>
                                             <option value="索赔结算">索赔结算</option>
                                             <option value="备用件发货">备用件发货</option>
                                             
                                         </select>
                                     </td>
                                 </tr>
                             </ItemTemplate>                           
                        </asp:repeater>
                        </tbody>
                      </table>
		</div>
		<div class="formBar">
			<ul>
				<!--<li><a class="buttonActive" href="javascript:;"><span>保存</span></a></li>-->
				<li id="AddAgentQlty2_BtnSave" ><div class="buttonActive"><div class="buttonContent"><button type="submit" > 提 交 </button></div></div></li>
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
				</li>
			</ul>
		</div>
	</form>
</div>

<script>
    $(document).ready(function () {
        $("#AddAgentQltySerialNumber").blur(function () {
            onrefreSerialNumberClick();
        });
       

    });

    function onrefreSerialNumberClick()
    {
        var $data = {};
        var $this = $("#AddAgentQltySerialNumber");
        $data["SerialNumber"] = $this.val();
        var url = "/AgentSys/ajaxDone.ashx?ajaxmethod=getuwarrantycard"
        $.ajax({
            type: 'post',
            url: url,
            data: $data,
            async: false,
            cache: false,
            dataType: 'json',
            success: function (json) {
                if (json.UWCID <= 0) {
                    alertMsg.warn('此机号还没有保修卡信息.相关客户信息请手工填写');
                    //$("#AddAgentQlty2_BtnSave").find("button").attr("disabled", "disabled");
                    return;
                }
                $("#AddAgentQlty2_BtnSave").find("button").removeAttr("disabled");
                for (var itm in json) {
                    if (itm == "IntoDate") {
                        $(".uwarrantycardInfo").find("[name='" + itm + "']").val(formatterdate(json[itm]));
                    }
                    else {
                        $(".uwarrantycardInfo").find("[name='" + itm + "']").val(json[itm]);
                    }

                }
            }
        });
    }

    function onAgentQltyDeleteUpload(id)
    {
       // imgShow, imgRelatively
        $("#imgShow" + id).attr("src", "/res/blank.png");
        $("#imgRelatively" + id).val("/res/blank.png");
    }

    function onAgentQltyUploadImgSuccess(file, data, response) {
        if (!response)
            return false;
        data = eval("(" + data + ")");
        if (!data.uploadResult)
        {
            alert(data.errMsg);
            return;
        }
        var $imgUploadPath = data.filePath;
        var $trageIds = data.customerInfo.split(",");
        $("#" + $trageIds[0]).attr("src", $imgUploadPath);
        $("#" + $trageIds[1]).val($imgUploadPath);
    }
    function onAgentQltyUploadFileSuccess(file, data, response) {
        if (!response)
            return false;
        data = eval("(" + data + ")");
        if (!data.uploadResult) {
            alert(data.errMsg);
            return;
        }
        var $imgUploadPath = data.filePath;
        var $trageId = data.customerInfo;       
        $("#" + $trageId).val($imgUploadPath);
    }

    //新增时需要处理 金额是否与合同金额一致
    function validateCallbackFTradeReceivablesAdd(form, callback) {
        var $form = $(form);
       
        $("#AddAgentQlty2_BtnSave").find("button").attr("disabled", "disabled").html("请稍侯......");
        setTimeout(function () { $("#AddAgentQlty2_BtnSave").find("button").removeAttr("disabled").html(" 提 交 "); }, 50000);

        return validateCallback(form, callback);
    }
</script>

